/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aviso.property.helpers;

import aviso.property.entity.Property;
import java.io.Serializable;

/**
 *
 * @author avgusti
 */
public class PropertyValuePair extends PropertyValueCountBase {

    String stringValue;

    public PropertyValuePair() {
    }

    public PropertyValuePair(Property property, String stringValue) {
        this.property = property;
        this.stringValue = stringValue;
    }

    public PropertyValuePair(Property property, String stringValue, Long count) {
        this.property = property;
        this.stringValue = stringValue;
        this.count=count;
    }


    public String getStringValue() {
        return stringValue;
    }

    public void setStringValue(String stringValue) {
        this.stringValue = stringValue;
    }

    public int getIntValue() {
        return Integer.parseInt(stringValue);
    }

    public Long getDateValue() {
        return Long.parseLong(stringValue);
    }

    public boolean getBoolValue() {
        return Boolean.parseBoolean(stringValue);
    }

    public Float getNumericValue() {
        return Float.parseFloat(stringValue);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final PropertyValuePair other = (PropertyValuePair) obj;
        if (other == null) {
            return false;
        }
        if (other.property == null) {
            return false;
        }
        if (other.property.getId() == null) {
            return false;
        }
        if (this.property != null && this.property.getId() != null && this.property.getId() != other.property.getId()) {
            return false;
        }
        if ((this.stringValue == null) ? (other.stringValue != null) : !this.stringValue.equals(other.stringValue)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 71 * hash + (this.property.getId() != null ? this.property.getId().hashCode() : 0);
        hash = 71 * hash + (this.stringValue != null ? this.stringValue.hashCode() : 0);
        return hash;
    }

    @Override
    public String getValueForCompare() {
        return stringValue;
    }
}
